/* ===== RESET AND BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    overflow: hidden;
}

/* ===== MAIN CONTAINER ===== */
/* Adapts to iframe (450px) or standalone mode (90vh) */
#game-container {
    width: 100%;
    height: 450px;
    position: relative;
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Standalone mode detection - when not in iframe */
@media (min-height: 500px) {
    body:not(.iframe-mode) #game-container {
        height: 90vh;
    }
}

/* ===== TOOLTIP ===== */
/* Central tooltip for displaying information without taking vertical space */
.tooltip {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    max-width: 80%;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.tooltip.show {
    opacity: 1;
}

/* ===== SCORE DISPLAY ===== */
/* Fixed position score counter */
.score-display {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 215, 0, 0.9);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 16px;
    color: #1e3c72;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.score-label {
    margin-right: 5px;
}

/* ===== PROGRESS BAR ===== */
.progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 99;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00d4ff 0%, #00ff88 100%);
    width: 0%;
    transition: width 0.5s ease;
}

/* ===== STORY PANEL ===== */
/* Narrative and choice display */
.story-panel {
    padding: 50px 20px 20px 20px;
    color: #fff;
    max-width: 800px;
    margin: 0 auto;
}

.story-text {
    font-size: 16px;
    line-height: 1.6;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 10px;
    border-left: 4px solid #00d4ff;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.choice-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    text-align: left;
    width: 100%;
    white-space: normal;
    line-height: 1.4;
}

.choice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.choice-btn:active {
    transform: translateY(0);
}

/* ===== GAME PANEL ===== */
/* Main electrolysis challenge area */
.game-panel {
    padding: 50px 15px 15px 15px;
    color: #fff;
}

.challenge-description {
    background: rgba(0, 0, 0, 0.5);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
    text-align: center;
    border: 2px solid #00d4ff;
}

/* ===== ELECTROLYSIS SETUP ===== */
.electrolysis-setup {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 15px;
}

.electrodes-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.electrode-zone {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

#anode-zone {
    border-color: #ff6b6b;
}

#cathode-zone {
    border-color: #4ecdc4;
}

.electrode-label {
    text-align: center;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 14px;
}

.electrolyte-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px;
    border: 2px solid #ffd93d;
}

.electrolyte-label {
    text-align: center;
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 14px;
}

/* ===== DROP ZONES ===== */
.drop-zone {
    min-height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 8px;
}

.drop-zone.drag-over {
    background: rgba(0, 212, 255, 0.2);
    border-color: #00d4ff;
    border-style: solid;
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
}

.drop-zone.filled {
    background: rgba(0, 255, 136, 0.2);
    border-color: #00ff88;
    border-style: solid;
}

/* ===== OPTIONS PANEL ===== */
.options-panel {
    background: rgba(0, 0, 0, 0.4);
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.draggable-items {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* ===== DRAGGABLE ITEMS ===== */
.draggable-item {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    cursor: grab;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    user-select: none;
    white-space: nowrap;
}

.draggable-item:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.5);
}

.draggable-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.draggable-item.placed {
    cursor: default;
    opacity: 0.6;
}

/* ===== ACTION BUTTONS ===== */
.action-container {
    display: flex;
    justify-content: center;
}

.submit-btn, .continue-btn {
    background: linear-gradient(135deg, #00ff88 0%, #00d4ff 100%);
    color: #1e3c72;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.submit-btn:hover, .continue-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 136, 0.5);
}

.submit-btn:active, .continue-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== FEEDBACK PANEL ===== */
.feedback-panel {
    padding: 50px 20px 20px 20px;
    color: #fff;
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
}

.feedback-text {
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.6;
}

.feedback-text.correct {
    border: 3px solid #00ff88;
    background: rgba(0, 255, 136, 0.1);
}

.feedback-text.incorrect {
    border: 3px solid #ff6b6b;
    background: rgba(255, 107, 107, 0.1);
}

/* ===== UTILITY CLASSES ===== */
.hidden {
    display: none !important;
}

/* ===== ANIMATIONS ===== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.pulse {
    animation: pulse 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.5s ease;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 600px) {
    .story-text {
        font-size: 14px;
        padding: 15px;
    }
    
    .choice-btn {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .draggable-item {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .electrodes-container {
        grid-template-columns: 1fr;
    }
}